********************************************************************************
********************************************************************************
***
*** Filename: 	Southern-Rights-Crisis.do
*** Author: 	David A Bateman
*** Function: 	Reproduces figures and tables for the southern rights elections
***				of 1850-1851, in the article Deeper Roots and in the online 
***				appendix. Analyses cover MS, GA, SC, AL, and TN. 
***	Last update: January 1, 2023
***
********************************************************************************
********************************************************************************

cd "..\Deeper Roots"
set more off

********************************************************************************
*** Set up MS and GA state files using the ICPSR data as well as collected votes  
*** on state conventions .
********************************************************************************
***
*** MS
use "Dataverse\ICPSR_00001\DS0134\Stata00001-0134.dta" , clear

keep V1-V3 V19 V145- V147 V156 V157 V162 V170- V176 V177 V178 V183 V184- V197
rename V1 state
rename V2 name
rename V3 county
rename V19 cd
drop if county==9999

foreach x of varlist V145- V197 {
	replace `x' = . if `x'==9999999
}

gen perWhig45 		= round(V145 / V147*100,.01)
gen perWhig47 		= round(V156 / V162*100,.01)
gen perWhig49MC 	= round(V177 / V183*100,.01)
gen perWhig49 		= round(V170 / V176*100,.01)
gen perUnion51 		= round(V187 / V190*100,.01)
gen perdem49		= round(V171 / V176*100,.01)
gen perSR51 		= round(V189 / V190*100,.01)
egen perWhig 		= rowmean(perWhig*)
gen perUnion51Cong	= round(V194 / V197*100,.01)
gen perSR51Cong		= round(V195 / V197*100,.01)

*** Merge county vote totals to Mississippi's southern rights convention. 
preserve
import delimited using "Secession-Crisis\Mississippi-1851.csv", clear
gen perUnionConv = round(union/total * 100, .01)
tempfile save
save `save', replace
restore
merge 1:1 county using `save', nogen

tempfile MS
save `MS', replace

*** GA
use "Dataverse\ICPSR_00001\DS0126\Stata00001-0126.dta" , clear
keep V1-V3 V22 V282 V284 V289 V298 V300 V305 V314-V321 V325 V327 V332  V333-V351
rename V1 state
rename V2 name
rename V3 county
rename V22 cd

foreach x of varlist V282- V351 {
	replace `x' = . if `x'==9999999
}

gen perWhig45 	= round(V282 / V289*100,.01)
gen perWhig46 	= round(V298 / V305*100,.01)
gen perWhig47 	= round(V314 / V321*100,.01)
gen perWhig48 	= round(V325 / V332*100,.01)
gen perWhig49 	= round(V333 / V340*100,.01)
gen perDem49	= round(V335 / V340*100,.01)
gen perUnion51 	= round(V345 / V348*100,.01)
gen perSR51 	= round(V346 / V348*100,.01)
egen perWhig 	= rowmean(perWhig*)
gen perSR51Cong		= round(V350 / V351*100,.01)
gen perUnion51Cong	= round(V349 / V351*100,.01)

*** Merge county vote totals to Georgia's southern rights convention. 
*** Each county had between 2 and 4 delegates, and attribution to the southern
*** rights and union/cooperation sides was not always clear. 
preserve
import delimited using "Dataverse\Files\Georgia-1850.csv", clear
gen perCoopConv = round(coop_total/total * 100, .01)
tempfile save
save `save', replace
restore
merge 1:1 county using `save', nogen

*** Append the Missippi file to the Georgia file. 
append using `MS'
gen swing	= perUnion51 - perWhig49

********************************************************************************
*** Merge in census data
merge 1:1 state county using "Dataverse\Census\census1850.dta", keepusing(totpop stot fctot wm2029 wm3039 wm4049 wm5059 wm6069 wm7079 wm8089 wm9099 wm100)
drop if _merge==2 
drop _merge

egen wm21 = rowtotal(wm2029- wm100)
drop wm2029- wm100

gen perEnslaved	= round(stot/totpop*100,0.01)
gen perfBlack	= round(fctot/totpop*100,0.01)


********************************************************************************
*** Create figures and tables for main paper and online appendix.
********************************************************************************

*** Figure 2 "Replication and Extension of Figure 5.1 in Deep Roots"
*** First Replicate Figure 5.1
lpoly  perUnion51 perEnslaved if state==46, ci	///
	graphreg(col(white)) ylab(0(20)100, nogrid angle(h) labsize(small))	///
	xlab(0(20)100, angle(h) labsize(small))	xtitle("Percentage Held in Slavery", size(small))	///
	ytitle("Percentage Union Vote, 1851", size(small)) title("Mississippi Governor", col(black) size(small))	///
	lineopts(lcol(black)) mcol(white) mlw(thin) mlc(black)	///
	legend(off)	name(rep51MS, replace) note("")
	
lpoly  perUnion51 perEnslaved if state==44, ci 	///
	graphreg(col(white)) ylab(0(20)100, nogrid angle(h) labsize(small))	///
	xlab(0(20)100, angle(h) labsize(small))	xtitle("Percentage Held in Slavery", size(small))	///
	ytitle("Percentage Union Vote, 1851", size(small)) title("Georgia Governor", col(black) size(small))	///
	lineopts(lcol(black)) mcol(white) mlw(thin) mlc(black)	///
	legend(off)	name(rep51GA, replace) note("")

***	Add 1849 partisan vote share
*** MS
regress perUnion51 c.perWhig49 if state==46
margins, at(perWhig49 = (5(10)65))
marginsplot, recast(line) recastci(rline)		///
	addplot(scatter perUnion51 perWhig if state==46, col(white) mlc(black) mlw(thin)	///
		|| function y = x, range(0 100) lcol(black) lw(vthin))	///
	ci1opts(recast(rarea) col(gs10) lw(vthin)) plot1opts(lcol(black))	///
	yscale(range(0 100)) ylab(0(20)100, nogrid labsize(small) angle(h))	///
	xscale(range(0 100)) xlab(0(20)100, nogrid labsize(small) angle(h))	///
	xtitle("Whig Vote, 1849", size(small))	///
	ytitle("Predicted Union Vote, 1851", size(small))	///
	graphreg(col(white)) title("", size(small) col(black))	///
	name(rep51MSc, replace) legend(off)

*** GA
regress perUnion51 c.perWhig49 if state==44
margins, at(perWhig49 = (5(10)85))
marginsplot, recast(line) recastci(rline)		///
	addplot(scatter perUnion51 perWhig if state==44, col(white) mlc(black) mlw(thin)	///
		|| function y = x, range(0 100) lcol(black) lw(vthin))	///
	ci1opts(recast(rarea) col(gs10) lw(vthin)) plot1opts(lcol(black))	///
	yscale(range(0 100)) ylab(0(20)100, nogrid labsize(small) angle(h))	///
	xscale(range(0 100)) xlab(0(20)100, nogrid labsize(small) angle(h))	///
	xtitle("Whig Vote, 1849", size(small))	///
	ytitle("Predicted Union Vote, 1851", size(small))	///
	graphreg(col(white)) title("", size(small) col(black))	///
	name(rep51GAc, replace) legend(off)
	
graph combine rep51MS rep51GA, graphreg(color(white)) imargin(small) name(graph1, replace)
graph combine  rep51MSc rep51GAc, graphreg(color(white)) imargin(small) name(graph2, replace)
graph combine graph1 graph2, rows(2) graphreg(color(white))
graph display Graph, ysize(11) xsize(8.5)

graph export "Dataverse\Figures\Figure-2.pdf", as(pdf) replace

*** Figure 3: "Swing from Whigs to Unionists between 1849 and 1851"
regress swing perEnslaved if state==46
lpoly swing perEnslaved if state==46, ci ///
	graphreg(col(white)) ylab(, nogrid angle(h) labsize(small))	///
	xlab(, angle(h) labsize(small))	xtitle("Percentage Held in Slavery", size(small))	///
	ytitle("Swing from Whigs to Unionists", size(small)) title("Mississippi Governor", col(black) size(small))	///
	lineopts(lcol(black)) mcol(white) mlw(thin) mlc(black)	///
	legend(off)	name(swingMS, replace) note("") yline(0, lc(black))

regress swing perEnslaved if state==44
lpoly swing perEnslaved if state==44, ci ///
	graphreg(col(white)) ylab(, nogrid angle(h) labsize(small))	///
	xlab(, angle(h) labsize(small))	xtitle("Percentage Held in Slavery", size(small))	///
	ytitle("Swing from Whigs to Unionists", size(small)) title("Mississippi Governor", col(black) size(small))	///
	lineopts(lcol(black)) mcol(white) mlw(thin) mlc(black)	///
	legend(off)	name(swingGA, replace) note("")  yline(0, lc(black))
	
graph combine swingGA swingMS, cols(2) graphreg(color(white)) ycommon name(swingMSGA, replace)
graph export "Dataverse\Figures\Figure-3.pdf", as(pdf) replace

********************************************************************************
*** Supplemental materials tables and figures. 
*** GA
eststo drop est*
eststo: regress perCoopConv perEnslaved if state==44
eststo: regress perCoopConv perWhig if state==44
eststo: regress perCoopConv c.perWhig##c.perEnslaved if state==44
margins, at(perEnslaved = (10(10)80) perWhig = (40 60)) vsquish
marginsplot, recast(line) recastci(rline)		///
	ci1opts(recast(rarea) col(gs10) lw(vthin)) plot1opts(lcol(black))	///
	ci2opts(col(black) lw(vthin) lp(dash)) plot2opts(lcol(black) lp(dash))	///
	yscale(range(0 100)) ylab(0(20)100, nogrid labsize(small) angle(h))	///
	xscale(range(10 70)) xlab(0(20)100, nogrid labsize(small) angle(h))	///
	xtitle("Percentage Held in Slavery", size(small))	///
	ytitle("Predicted Unionist Vote Share, 1850", size(small))	///
	graphreg(col(white)) title("Convention", size(small) col(black))		///
	legend(size(small) order(3 4) label(3 "Democratic District") label(4 "Whig District") symxsize(large))	///
	name(convention, replace)

eststo: regress perUnion51 perEnslaved if state==44
eststo: regress perUnion51 perWhig if state==44
eststo: regress perUnion51 c.perWhig##c.perEnslaved if state==44
margins, at(perEnslaved = (10(10)80) perWhig = (40 60)) vsquish
marginsplot, recast(line) recastci(rline)		///
	ci1opts(recast(rarea) col(gs10) lw(vthin)) plot1opts(lcol(black))	///
	ci2opts(col(black) lw(vthin) lp(dash)) plot2opts(lcol(black) lp(dash))	///
	yscale(range(0 100)) ylab(0(20)100, nogrid labsize(small) angle(h))	///
	xscale(range(10 70)) xlab(0(20)100, nogrid labsize(small) angle(h))	///
	xtitle("Percentage Held in Slavery", size(small))	///
	ytitle("Predicted Unionist Vote Share, 1851", size(small))	///
	graphreg(col(white)) title("Governor", size(small) col(black))		///
	legend(size(small) order(3 4) label(3 "Democratic District") label(4 "Whig District") symxsize(large))	///
	name(governor, replace)	

eststo: regress perUnion51Cong perEnslaved if state==44
eststo: regress perUnion51Cong perWhig if state==44
eststo: regress perUnion51Cong c.perWhig##c.perEnslaved if state==44
margins, at(perEnslaved = (10(10)80) perWhig = (40 60)) vsquish
marginsplot, recast(line) recastci(rline)		///
	ci1opts(recast(rarea) col(gs10) lw(vthin)) plot1opts(lcol(black))	///
	ci2opts(col(black) lw(vthin) lp(dash)) plot2opts(lcol(black) lp(dash))	///
	yscale(range(0 100)) ylab(0(20)100, nogrid labsize(small) angle(h))	///
	xscale(range(10 70)) xlab(0(20)100, nogrid labsize(small) angle(h))	///
	xtitle("Percentage Held in Slavery", size(small))	///
	ytitle("Predicted Unionist Vote Share, 1851", size(small))	///
	graphreg(col(white)) title("Congress", size(small) col(black))		///
	legend(size(small) order(3 4) label(3 "Democratic District") label(4 "Whig District") symxsize(large))	///
	name(congress, replace)	
	
eststo: regress swing perEnslaved if state==44

grc1leg convention governor congress, graphreg(col(white)) imargin(tiny) rows(1)	///
	title("Georgia", col(black) size(small)) name(georgia_A1, replace)

*** Table A1
esttab , noconstant  	///
	drop( _cons) scalar(F) se  ///
	coeflabels(perEnslaved "\% Enslaved" perWhig "\% Whig (1845-1849)" c.perWhig#c.perEnslaved "\% Enslaved * \% Whig")	///
	title(Georgia 1850-51) 	parentheses ///
	mtitles("Convention" "Convention" "Convention" "Governor" "Governor" "Governor" "Congress" "Congress" "Congress" "Swing")	///
	nogaps nodepvars nonumbers	compress   ///
	stats(N r2 F, fmt(%9.0g a3)) b(a2) replace
eststo drop est*
eststo: regress perUnionConv perEnslaved if state==46
eststo: regress perUnionConv perWhig if state==46
eststo: regress perUnionConv c.perWhig##c.perEnslaved if state==46
margins, at(perEnslaved = (10(10)90) perWhig = (30 50)) vsquish
marginsplot, recast(line) recastci(rline)		///
	ci1opts(recast(rarea) col(gs10) lw(vthin)) plot1opts(lcol(black))	///
	ci2opts(col(black) lw(vthin) lp(dash)) plot2opts(lcol(black) lp(dash))	///
	yscale(range(0 100)) ylab(0(20)100, nogrid labsize(small) angle(h))	///
	xscale(range(0 100)) xlab(0(20)100, nogrid labsize(small) angle(h))	///
	xtitle("Percentage Held in Slavery", size(small))	///
	ytitle("Predicted Unionist Vote Share, 1851", size(small))	///
	graphreg(col(white)) title("Convention", size(small) col(black))		///
	legend(size(small) order(3 4) label(3 "Democratic District") label(4 "Whig District") symxsize(large))	///
	name(convention, replace)

eststo: regress perUnion51 perEnslaved if state==46
eststo: regress perUnion51 perWhig if state==46
eststo: regress perUnion51 c.perWhig##c.perEnslaved if state==46
margins, at(perEnslaved = (10(10)90) perWhig = (30 50)) vsquish
marginsplot, recast(line) recastci(rline)		///
	ci1opts(recast(rarea) col(gs10) lw(vthin)) plot1opts(lcol(black))	///
	ci2opts(col(black) lw(vthin) lp(dash)) plot2opts(lcol(black) lp(dash))	///
	yscale(range(0 100)) ylab(0(20)100, nogrid labsize(small) angle(h))	///
	xscale(range(0 100)) xlab(0(20)100, nogrid labsize(small) angle(h))	///
	xtitle("Percentage Held in Slavery", size(small))	///
	ytitle("Predicted Unionist Vote Share, 1851", size(small))	///
	graphreg(col(white)) title("Governor", size(small) col(black))		///
	legend(size(small) order(3 4) label(3 "Democratic District") label(4 "Whig District") symxsize(large))	///
	name(governor, replace)	

eststo: regress perUnion51Cong perEnslaved if state==46
eststo: regress perUnion51Cong perWhig if state==46
eststo: regress perUnion51Cong c.perWhig##c.perEnslaved if state==46
margins, at(perEnslaved = (10(10)90) perWhig = (30 50)) vsquish
marginsplot, recast(line) recastci(rline)		///
	ci1opts(recast(rarea) col(gs10) lw(vthin)) plot1opts(lcol(black))	///
	ci2opts(col(black) lw(vthin) lp(dash)) plot2opts(lcol(black) lp(dash))	///
	yscale(range(0 100)) ylab(0(20)100, nogrid labsize(small) angle(h))	///
	xscale(range(0 100)) xlab(0(20)100, nogrid labsize(small) angle(h))	///
	xtitle("Percentage Held in Slavery", size(small))	///
	ytitle("Predicted Unionist Vote Share, 1851", size(small))	///
	graphreg(col(white)) title("Congress", size(small) col(black))		///
	legend(size(small) order(3 4) label(3 "Democratic District") label(4 "Whig District") symxsize(large))	///
	name(congress, replace)	

eststo: regress swing perEnslaved if state==46

grc1leg convention governor congress, graphreg(col(white)) imargin(tiny) rows(1) 	///
	title("Mississippi", col(black) size(small)) name(mississippi_A1, replace)

*** Figure A1: "Predicted Unionist Vote in Georgia and Mississippi"
grc1leg georgia_A1 mississippi_A1, graphreg(col(white)) imargin(tiny) ycommon rows(2)
graph export "Dataverse\Figures\Figure-A1.pdf", as(pdf) replace
	
*** Table A2: "Vote for Unionist Candidate in Mississippi, 1851"
esttab , noconstant  	///
	drop( _cons) scalar(F) se  ///
	coeflabels(perEnslaved "\% Enslaved" perWhig "\% Whig (1845-1849)" c.perWhig#c.perEnslaved "\% Enslaved * \% Whig")	///
	title(Mississippi 1851) 	parentheses ///
	mtitles("Convention" "Convention" "Convention" "Governor" "Governor" "Governor" "Congress" "Congress" "Congress" "Swing")	///
	nogaps nodepvars nonumbers	compress   ///
	stats(N r2 F, fmt(%9.0g a3)) b(a2) replace	

********************************************************************************
*** South Carolina also held elections for a southern rights convention. The more
*** extreme positions common in this state meant that it was a contest between 
*** outright secessionists and those who wanted to organize cooperation with 
*** other southern states.
********************************************************************************

*** Figure 4: "Slavery and Cooperation versus Secession in South Carolina"
import delimited using "Dataverse\Files\South-Carolina-1851-Convention.csv", clear

*** Two delegates elected from all districts. 
*** Coop are cooperationists; sece are secessionists.
egen coop = rowtotal(c1coop c2coop), missing
egen sece = rowtotal(c1sec c2sec), missing
egen total = rowtotal(c1coop c2coop c1sec c2sec), missing
gen perCoop = round(coop/total*100,0.01)

lpoly perCoop perenslaved ,  ci graphreg(color(none)) 				///
	lineopt(lc(black)) msym(O) mcol(white) mlc(black) mlw(thin)	///
	xlabel(25(10)95, labsize(small))	legend(off)								///
	ylabel(0(20)100, labsize(small) nogrid angle(h))					///
	ytitle("Cooperationist Vote 1851", size(small))				///
	xtitle("Percentage of County Held in Slavery", size(small))	///
	name(graph1, replace)	note("")							///
	title("Cooperationist Vote", col(black) size(medium))

regress perCoop perenslaved
margins, at(perenslaved = (25(10)95))
marginsplot, recastci(rarea) recast(line)	///
	ci1opts(col(gs12)) plot1opts(lcol(black))	///
	graphregion(color(none)) ylabel(0(20)100, labsize(small) nogrid angle(h))	///
	xlab(, labsize(small)) 										///
	xtitle("Percentage of County Held in Slavery", size(small))	///
	ytitle("Predicted Vote for Cooperation", size(small))	///
	name(graph2, replace)											///
	title("South Carolina Convention, 1851", col(black) size(medium))

graph combine graph1 graph2, graphreg(col(white))
graph export "Dataverse\Figures\Figure-4.pdf", as(pdf) replace

********************************************************************************
*** Alabama
*** The AL elections were considerably after the crisis had been resolved. The 
*** gubernatorial candidate embraced the Georgia Resolutions and won the 
*** nomination of both Whigs and Democratic organization. At the congressional 
*** level the Southern Rights ran only Democrats but the Unionists ran both 
*** Democrats and Whigs. 
***
********************************************************************************
use "Dataverse\ICPSR_00001\DS0113\Stata00001-0113.dta" , clear

keep V1-V3 V19 V161-V167 V175-V202 V203-V241
rename V1 state
rename V2 name
rename V3 county
rename V19 cd
drop if county==9999
foreach x of varlist V161- V241 {
	replace `x' = . if `x'==9999999
}

*** Party codes for the 1851 congressional elections. See ICPSR_00001\DS0204\00001-0204-Documentation,txt
*** 204: Union Whig
*** 206: Unionist
*** 528: Union Democrat
*** 737: Secession Democrat
*** 925: Southern Rights Democrat
*** 939: Secessionist

egen union51_icpsr	= rowtotal(V235 V236 V237), missing
egen sr51_icpsr		= rowtotal(V238 V239 V240), missing
gen perSR51_icpsr	= round(sr51_icpsr/V241*100,0.01)
gen perUnion51_icpsr= round(union51_icpsr/V241*100,0.01)

gen perDem48P 		= round(V211/V216*100,.01)

gen perWhig44 		= round(V161 / V167*100,.01)
gen perWhig45MC 	= round(V182 / V188*100,.01) if (V182!=0)
replace perWhig45MC = round(V184 / V188*100,.01) if (V184!=0 & perWhig45MC==.)
gen perWhig47 		= round(V196 / V202*100,.01)
gen perWhig48P 		= round(V210 / V216*100,.01)
egen perWhig 		= rowmean(perWhig*)

merge 1:1 state county using "Dataverse\Census\census1850.dta", keepusing(totpop stot fctot wm2029 wm3039 wm4049 wm5059 wm6069 wm7079 wm8089 wm9099 wm100)
drop if _merge==2 
drop _merge

egen wm21 = rowtotal(wm2029- wm100)
drop wm2029- wm100

gen perEnslaved	= round(stot/totpop*100,0.01)
gen perfBlack	= round(fctot/totpop*100,0.01)

*** A large number of counties are missing congressional vote data in the 
*** ICPSR files for 1851 (especially from the 3rd and 5th districts). 
*** This data has been filled in using local newspapers.
*** The most significant source was The Weekly Advertiser (Sept 30-1851, p.2), 
*** which provided vote shares for the 3rd district as well as most counties in 
*** 1st, 2nd, 4th, and 7th districts. Data on the 5th district was collected from
*** The Independent Monitor (14-Aug) and the Sumter County Whig (12-Aug)

preserve
import delimited using "Dataverse\Files\Alabama-Candidate-Party.csv", clear
tempfile save
save `save', replace
restore
merge 1:1 county using `save', nogen

*** The corrected congressional election data correlates at very high level with
*** the observed ICPSR votes.
pwcorr sr51_corrected sr51_icpsr

gen perSR51			= round(sr51_corrected/total51_corrected*100,0.01)
gen perUnion51		= round(union51_corrected/total51_corrected*100,0.01)

*** Choctaw and Washington are combined in the recovered vote data. Easiest just to 
*** drop them, but combining their enslaved population doesn't change the results.
/*
summ stot if  county==1290 | county==230
loc temp1 = r(sum)
summ totpop if  county==1290 | county==230
loc temp2 = r(sum)
replace perEnslaved = round(`temp1'/`temp2'*100,0.01) if county==1290
drop if county==230
*/
drop if county==1290 | county==230
gen swing	= perUnion51 - perWhig48P

*** Straightforward regressions of slavery and vote share do not show any 
*** relationship in Alabama. As discussed in the online appendix, this obscures
*** important ways in which enslavement shaped positions. We instead examine
*** whether slavery had a role in support for Southern Right or secessionist
*** candidates conditional on whether the candidate was from the same party as
*** previously was dominant in a county. 
*** The Whigs were the minority party. Set Whig-aligned counties as the median 
*** share of the average Whig vote.
gen aligned = 1 if perWhig>47 & perWhig!=. & whigcandidate==1
replace aligned = 1 if perWhig<=47 & perWhig!=. & whigcandidate==0
replace aligned = 0 if perWhig>47 & perWhig!=. & whigcandidate==0
replace aligned = 0 if perWhig<=47 & perWhig!=. & whigcandidate==1

label define whigcandidate51 0 "Democratic Candidate" 1 "Whig Candidate"
label values whigcandidate51 whigcandidate51
label define aligned 0 "Un-Aligned Candidate" 1 "Aligned Candidate"
label values aligned aligned

eststo drop est*
regress perUnion51 c.perEnslaved##i.aligned##c.perWhig
margins, at(perEnslaved= (10(10)70) aligned = (0 1) perWhig = (35  55))
marginsplot, bydimension(aligned) ///
	subtitle(, size(small) bcolor(gs14)) ///
	recast(line) recastci(rline)		///
	ci1opts(recast(rarea) col(gs10) lw(vthin)) plot1opts(lcol(black))	///
	ci2opts(col(black) lw(vthin) lp(dash)) plot2opts(lcol(black) lp(dash))	///
	byopts(title("Alabama Congressional Elections 1851", col(black) size(small)) graphreg(col(white)) compact ) 	///
	yscale(range(0 100)) ylab(0(20)100, nogrid labsize(small) angle(h))	///
	xscale(range(10 70)) xlab(10(20)70, nogrid labsize(small) angle(h))	///
	xtitle("Percentage of County Held in Slavery", size(small))	///
	ytitle("Predicted Unionist Vote Share in 1851", size(small))	///
	legend(size(small) order(3 4) label(3 "Democratic Counties") label(4 "Whig Counties") symxsize(large))	

*** Figure A2: "Predicted Unionist Vote in Alabama Congressional Elections, 1851"
graph export "Dataverse\Figures\Figure-A2.pdf", as(pdf) replace

eststo: regress perUnion51 c.perEnslaved perWhig if aligned==1
eststo: regress perUnion51 c.perEnslaved perWhig if aligned==0
eststo: regress swing perEnslaved
lpoly swing perEnslaved, ci ///
	graphreg(col(white)) ylab(, nogrid angle(h) labsize(small))	///
	xlab(, angle(h) labsize(small))	xtitle("Percentage Held in Slavery", size(small))	///
	ytitle("Swing from Whigs to Unionists", size(small)) title("Alabama Congress", col(black) size(small))	///
	lineopts(lcol(black)) mcol(white) mlw(thin) mlc(black)	///
	legend(off)	name(swingAL, replace) note("") yline(0, lc(black))

esttab , noconstant  	///
	drop( _cons) scalar(F) se  ///
	coeflabels(perEnslaved "\% Enslaved" perWhig "\% Whig (1844-1848)" c.perWhig#c.perEnslaved "\% Enslaved * \% Whig")	///
	title(Alabama 1851) 	parentheses ///
	mtitles("Aligned Candidate" "Misaligned Candidate" "Swing")	///
	nogaps nodepvars nonumbers	compress   ///
	stats(N r2 F, fmt(%9.0g a3)) b(a2) replace	

*** Figure A3: "Swing from Whigs to Unionists in Georgia, Mississippi, and Alabama"
graph combine swingGA swingMS swingAL, graphreg(col(white)) imargin(tiny) rows(1) ycommon
graph export "Dataverse\Figures\Figure-A3.pdf", as(pdf) replace

********************************************************************************
*** Tennessee
*** TN did not have Southern Right candidates elected. But it was the site of an
*** effort to hold a southern conference that would unite the region around a
*** common position. The Tennessee legislature voted against appointing delegates,
*** a vote that largely divided high- and low-enslavement regions. Individual 
*** counties then decided whether or not to send delegations, and sent as many 
*** or as few as they wanted. Participation in the convention provides a rough 
*** measure of interest in this state for coordinating a southern position on 
*** slavery.
***
********************************************************************************
import delimited using "Dataverse\Files\Tennessee-Nashville-Convention-Delegates.csv", clear

ttest perenslaved, by(elected)
bys county : egen count = total(elected)

tw lpolyci count perenslaved if county!="DAVIDSON",  bw(4) graphreg(color(none)) clcolor(black)						///
	|| (scatter count perenslaved if county!="DAVIDSON", msym(O) mcol(white) mlc(black) mlw(thin))					///
	|| (scatter count perenslaved if county=="DAVIDSON", msym(O) mcol(white) mlc(black) mlw(thin) mlabel(county) mlabcol(black))		///
	, xlabel(0(10)60, labsize(small))	legend(off)								///
	ylabel(0(5)35, labsize(small) nogrid angle(h))					///
	ytitle("Number of Delegates Sent to Convention", size(small))				///
	xtitle("Percentage of County Held in Slavery", size(small))	///
	name(TN1, replace)	note("")							///
	title("Number of Delegates", col(black) size(small))


collapse perenslaved elected distance, by(county)
ttest perenslaved, by(elected)
logit elected perenslaved distance
margins, at(perenslaved = (0(5)50))
marginsplot, recastci(rarea) recast(line)	///
	ci1opts(col(gs10)) plot1opts(lcol(black))	///
	graphregion(color(none)) ylabel(0(.2)1, labsize(small) nogrid angle(h))	///
	xlab(, labsize(small)) 										///
	xtitle("Percentage of County Held in Slavery", size(small))	///
	ytitle("Predicted Probability of Electing Delegates", size(small))	///
	name(TN2, replace)											///
	title("Probability of Electing Delegates", col(black) size(small))

graph combine TN1 TN2, graphreg(col(white))	///
	note("Davidson County (Nashville) was site of convention, and is excluded from polynominal; distance included in logit regression.", size(vsmall))
	
*** Figure A5: "Tennessee Counties Sending Delegates to Nashville Convention, 1850"
graph export "Dataverse\Figures\Figure-A5.pdf", as(pdf) replace

********************************************************************************
*** Kentucky
*** KY was not part of the Southern Rights movement of 1850-51. But its elections
*** that year have some bearing on enslavement, since one of the major candidates
*** was Cassius Clay, a well known opponent of slavery. His supporters were called
*** abolitionists, though this was at least as much an effort to discredit them. 
*** They were not immediate abolitionists, but did envision putting slavery on the 
*** path to abolition in the state. 
***
***
********************************************************************************
*** Set up KY state files using the ICPSR data.
********************************************************************************
***
**KY
use "Dataverse\ICPSR_00001\DS0150\Stata00001-0150.dta" , clear

keep V1-V3 V189- V278
rename V1 state
rename V2 name
rename V3 county
drop if county==9999

foreach x of varlist V189- V278 {
	replace `x' = . if `x'==9999999
}

gen perEman51	= round(V193 / V195*100,.01)
gen perFrDem52	= round(V210 / V211*100,.01)
gen perIndDm53	= round(V218 / V221*100,.01)
gen perUnDm59	= round(V271 / V273*100,.01)

********************************************************************************
*** Merge in census data
merge 1:1 state county using "Dataverse\Census\census1850.dta", keepusing(totpop stot fctot wm2029 wm3039 wm4049 wm5059 wm6069 wm7079 wm8089 wm9099 wm100)
drop if _merge==2 
drop _merge

egen wm21 = rowtotal(wm2029- wm100)
drop wm2029- wm100

gen perEnslaved	= round(stot/totpop*100,0.01)
gen perfBlack	= round(fctot/totpop*100,0.01)

tw 	lpolyci perEman51 perEnslaved if name!="MADISON",clcol(black)			///
	|| scatter perEman51 perEnslaved if name!="MADISON" & name!="GARRARD",	///
		mlw(thin) mlc(black) mcol(white)									///
	|| (scatter perEman51 perEnslaved if name=="MADISON" | name=="GARRARD",	///
		mlw(thin) mlc(black) mcol(white) mlabel(name) mlabcol(black))		///
	, graphreg(col(none)) ylab(, nogrid angle(h) labsize(small))			///
	xlab(, labsize(small)) leg(off)											///
	xtitle("Percentage of County Held in Slavery", size(small))				///
	ytitle("Emancipationist Vote, 1851", size(small))						///
	title("Emancipationist Vote", col(black) size(small)) name(KY1, replace)
	
regress perEman51 perEnslaved perfBlack if name!="MADISON" 
margins, at(perEnslaved= (0(5)35))
marginsplot, subtitle(, size(small) bcolor(gs14)) ///
	recast(line) recastci(rline)		///
	ci1opts(recast(rarea) col(gs10) lw(vthin)) plot1opts(lcol(black))	///
	graphreg(col(none)) ylab(, nogrid labsize(small) angle(h))	///
	yscale(range(0 6)) xlab(, nogrid labsize(small) angle(h))	///
	xtitle("Percentage of County Held in Slavery", size(small))	///
	ytitle("Predicted Emancipationist Vote, 1851", size(small))	///
	legend(off) title("Predicted Emancipationist Vote", col(black) size(small)) ///
	name(KY2, replace)
	
graph combine KY1 KY2, graphreg(col(white)) imargin(small)	///
	note("Madison County was Cassius Clay's home county and the site of explicit abolitionist in-migration; excluded from smoothed line and regression.", size(vsmall))
	
*** Figure A4: "Gubernatorial Vote for Cassius Clay, Kentucky 1851"
graph export "Dataverse\Figures\Figure-A4.pdf", as(pdf) replace
